<link rel="import" href="../../bower_components/polymer/polymer-element.html">
<link rel="import" href="../../bower_components/app-localize-behavior/app-localize-behavior.html">
<dom-module id="i18n-demo">
  <template>
    <style>
      :host{
        display: block;
      }
    </style>
    <div>
        {{localize('hello', 'name', '钟钟')}}

        <button on-click="switchLanguage">切换语言</button>
    </div>
    
  </template>

  <script>
    /**
     * @I18nDemo
     * @polymer
     */
    class I18nDemo extends Polymer.mixinBehaviors([Polymer.AppLocalizeBehavior],Polymer.Element ){
      static get is() { return 'i18n-demo'; }
      static get properties(){
        return {
         language:{
             value:"zh"
         },
         resources:{
             value(){
                 return {
                     'zh':{"hello":"你好，我是{name}"},
                     'en':{"hello":"Hello,my name is {name}"}
                 }
             }
         }
        }
      }
      switchLanguage(){
          if("zh" === this.language){
              this.language = "en";
          }else{
              this.language = "zh";
          }
      }
    }
    window.customElements.define(I18nDemo.is, I18nDemo);

  </script>
</dom-module>


